<h2>Images</h2>
<%=error_message_on :viewable, :images %>
<table class="basic-table">
  <thead>
    <tr>
      <th>Image</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>
    <% viewable.images.each do |i| %>
      <tr>
        <td><%= image_tag i.public_filename(:small) %></td>
        <td>
          <%= link_to_remote "Delete",
                             :url => {:controller => 'images', :action => 'delete', :id=> i},
                             :before => "Element.show('img_busy_indicator')", 
                             :complete => "Element.hide('img_busy_indicator')",
                             :confirm => "Are you sure you want to delete this image?",
                             :update => 'image-listing' %>
        </td>
      </tr>
    <% end %>
    <% if viewable.images.empty? %>
      <tr>
        <td colspan="3">None Available.</td>
      </tr>
    <% end %>
  </tbody>
</table>
<% unless viewable.new_record? %>
  <span id="new-img-link">
    <%= link_to_remote "New Image",
                       :url => {:controller => 'images', :action => 'new'},
                       :before => "Element.hide('new-img-link');Element.show('img_busy_indicator')", 
                       :complete => "Element.hide('img_busy_indicator')",
                       :update => 'new-image' %>
  </span>
  <%= image_tag "spinner.gif", :plugin=>"railscart", :style => "display:none", :id => 'img_busy_indicator' %>
<% end %>
<br/>
<div id="new-image"></div>
<br/>